home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
SMALLTAL
/
SMALLTAL.K_R
< prev
Wrap
Text File
|
1990-07-16
|
4KB
|
97 lines
'The following source-code implements a modified ChangeListView recover
mechanism which allows you to specify how many snapshots you want to go back.
Despite its simplicity, it has been very useful to us over the years and
should have been made public domain software long ago.
Try: "ChangeListView recover"
Have fun, Pieter.
----------------------cut here--------------------------'!
!ChangeList methodsFor: 'private'!
find: aString lastMinus: anInteger in: aStream
"Same as findLast:in: if anInteger would be zero. This methods assumes
that streaming forward is more efficient than streaming backward, and
will therefore go faster with increasing jumpSize. However, if snapshots
happen to follow each other within jumpSize characters in the changes
file, it will include more snapshots than specified - P.S. van der Meulen"
| firstChar endPosition position count index lastEnd lastMinus jumpSize |
jumpSize _ 1000.
lastMinus _ anInteger.
lastEnd _ nil.
firstChar _ aString first.
aStream setToEnd.
position _ aStream position.
[endPosition _ position.
lastEnd == nil and: [(position _ endPosition - jumpSize max: 0) < endPosition]]
whileTrue:
[aStream position: position.
count _ endPosition - position.
[count > 0]
whileTrue:
[count _ count - 1.
aStream next = firstChar
ifTrue:
[index _ 2.
[index <= aString size and: [(aString at: index) = aStream next]]
whileTrue: [index _ index + 1].
index > aString size
ifTrue: [lastMinus > 0
ifTrue: [lastMinus _ lastMinus - 1]
ifFalse: [lastEnd _ aStream position]]
ifFalse: [aStream position: endPosition - count]]]].
^lastEnd! !
!ChangeList methodsFor: 'initialize-release'!
recover: anInteger file: aFileStream
"Recover all the changes from a .changes file
since the <last minus anInteger> snapshots.
Written by Pieter S. van der Meulen."
| position |
position _ self find: '
''----SNAPSHOT----'
lastMinus: anInteger
in: aFileStream.
position isNil
ifTrue: [position _ 0].
aFileStream position: position.
aFileStream upTo: Character cr.
self scanFile: aFileStream! !
!ChangeListView class methodsFor: 'instance creation'!
recoverLastMinus: anInteger
"Open a view of the current changes file since the <last minus anInteger> snapshot."
self openOn: (ChangeList new recover: anInteger file:
((Smalltalk includesKey: #Filename)
ifTrue: [(Filename named: (SourceFiles at: 2) name) readStream] "Version 2.5"
ifFalse: [SourceFiles at: 2])) "Version 2.3"
"ChangeListView recoverLastMinus: 1"!
recover
"Open a view of the current changes file since the last snapshot, or more
depending on the users request. Modified by Pieter S. van der Meulen."
self recoverLastMinus:
(FillInTheBlank
request:
'From how many snapshots do you want to recover changes?
(Enter 0 for the current changes since the last snapshot.)'
initialAnswer: '0') asNumber
"ChangeListView recover"! !
'----------------------cut here--------------------------'!
--
---------------------------------------------
P.S. van der Meulen, MS 02 prls!pieter
PRLS, Signetics div. of NAPC -----------
811 E.Arques Avenue, Sunnyvale, CA 94088-3409